<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="/resource/UserPwoer.tld" prefix="p"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	pageContext.setAttribute("fnId", request.getAttribute("fnId"));
	pageContext.setAttribute("userPwoer", request.getSession().getAttribute("userPwoer"));
%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<LINK rel="Bookmark" href="../images/favicon.ico">
<!-- 本框架基本脚本和样式 -->
<script type="text/javascript"
	src="${path }/resource/js/jquery-2.1.4.min.js"></script>
<script type="text/javascript"
	src="${path }/resource/js/systools/MBase.js"></script>
<!-- 导出  -->
<script type="text/javascript"
	src="${path }/resource/plugin/ajaxfileupload.js"></script>
<style>
.ibox-content {
	position: relative
}

.money {
	position: absolute;
	bottom: -23px;
	right: 110px;
	font-size: 20px;
	color: #3983de;
}
</style>

</head>
<body class="gray-bg">
	<nav class="huiNav">
		<i class="fa fa-home"></i> 首页 <span>&gt;</span>付款管理<span>&gt;</span>院校管理费
		<a class="btn btn-info  btn-sm pull-right"
			href="javascript:location.replace(location.href);" title="刷新"><i
			class="fa fa-refresh"></i></a>
	</nav>

	<div class="ibox-content">
		<!-- 搜索框部分start -->
		<p:btn value="serch">
			<form class="form-inline" id="serchform">
				<div class="form-group mr-20">
					<label for="exampleInputName2">学生姓名</label> <input name="stuName"
						id="stuName" type="text" class="form-control">
				</div>

				<label for="exampleInputName2">班级</label>
				<div class="form-group mr-20">
					<div style="width: 160px;">
						<select name="stuClass" id="stuClass"
							class="form-control autoFull select2"
							data-url="${path}/admin/tabClass/showAllClass"
							data-filed="claName" data-value="claId">
							<option value="">--请选择所在班级--</option>
						</select>
					</div>
				</div>

				<label for="exampleInputName2">来自院校</label>
				<div class="form-group mr-20">
					<div style="width: 160px;">
						<select name="stuSchool" id="stuSchool"
							class="form-control autoFull select2"
							data-url="${path}/admin/studentinfo/showAllSchool"
							data-def="${obj.stuSchool }" data-filed="name" data-value="name"
							datatype="*" nullmsg="院校不能为空">
							<option value="">--请选择所属院校--</option>
						</select>
					</div>
				</div>

				<div class="form-group mr-20">
					<label for="exampleInputName2">领款人</label> <input name="ucPeople"
						id="ucPeople" type="text" class="form-control">
				</div>

				<br />
				<br />
				<div class="form-group mr-20">
					<label for="exampleInputName2">领款起止日期</label> <input
						name="beginTime" id="beginTime" type="text"
						class="form-control datetimepicker">— <input
						name="endTime" id="endTime" type="text"
						class="form-control datetimepicker">
				</div>

				<button onclick="myGrid.serchData()" type="button"
					class="btn btn-info btn-sm">
					<i class="fa fa-search "></i> 搜索
				</button>
				<button type="button" onclick="MForm.reset('#serchform')"
					class="btn btn-info btn-sm">
					<i class="fa fa-refresh "></i> 重置
				</button>
			</form>
		</p:btn>
		<!-- 搜索框部分en -->
		<div class="option-bar">
			<%-- <p:btn value="dels">
				<button onclick="myGrid.delItems('ucId')" type="button" class="btn btn-danger btn-sm">
					<i class="fa fa-trash"></i>批量删除
				</button>
			</p:btn> --%>
			<p:btn value="add">
				<button onclick="openAdd()" type="button"
					class="btn btn-success btn-sm">
					<i class="fa fa-plus"></i> 新增
				</button>
			</p:btn>
			<p:btn value="import">
				<button onclick="openImport()" type="button"
					class="btn btn-warning btn-sm">
					<i class="fa fa-cloud-upload"></i> 导入
				</button>
			</p:btn>
			<p:btn value="export">
				<button onclick="exportExcel()" type="button"
					class="btn btn-info btn-sm">
					<i class="fa fa-cloud-download"></i> 导出
				</button>
			</p:btn>
		</div>
		<table id="mgrid">
			<thead>
				<tr>
					<th data-checkbox="true"></th>
					<th data-formatter="MGrid.indexfn" data-align="center"
						data-width="30px">序号</th>
					<th data-field="stuName">学生姓名</th>
					<th data-field="claName">班级</th>
					<th data-field="stuSchool">院校</th>
					<th data-field="stuIfschool">是否院校毕业</th>
					<th data-field="zoMoney">管理费金额</th>
					<th data-field="ucDept">领款部门</th>
					<th data-field="ucRemarks">备注</th>
					<!-- <th data-align="center"  data-width="180px" data-field="ucId" data-formatter="buidOperate">操作</th> -->
				</tr>
			</thead>
		</table>
		<div class="money">
			<font>管理费总额：<span id="manageTotals"></span></font>
		</div>
	</div>

	<script type="text/javascript">
		var myGrid;
		$(function() {
			//带搜索的下拉框
			$(".select2").select2({
				'width' : '100%'
			});
			$(".select2").trigger("blur");
			//初始化下拉框
			MTools.autoFullSelect();
			//初始化日期控件
			MTools.ininDatetimepicker({
				listenBlur : true
			});

			//有删除权限
			var delUrl = "";
			<p:btn value="dels">
			delUrl = "${path}/admin/schoolmanage/del";
			</p:btn>

			myGrid = MGrid.initGrid({
				url : "${path}/admin/schoolmanage/showList",
				delUrl : delUrl,
				onLoadSuccess : function(data) {
					//放到请求中
					$.AjaxProxy({
						p : {
							stuName : $("#stuName").val(),
							stuClass : $("#stuClass").val(),
							stuSchool : $("#stuSchool").val(),
							ucPeople : $("#ucPeople").val(),
							beginTime : $("#beginTime").val(),
							endTime : $("#endTime").val(),
						}
					}).invoke(
							"${path}/admin/schoolmanage/findModel",
							function(loj) {
								//管理费总金额
								var manageTotals = 0;
								for (var j = 0; j < loj.getRowCount(); j++) {
									manageTotals += new Number(loj.getString(j,
											"zoMoney"));
								}
								$("#manageTotals").html(manageTotals);
							});
				},

				detailView : true,
				onExpandRow : function(index, row, $detail) {
					console.log(row);
					InitSubTable(index, row, $detail);
				}
			});
		});
		function buidOperate(value, row, index) {
			var html = '';
			<p:btn value="edit">
			html += '<button class="btn btn-default btn-sm mr-5" onClick="openEdit('
					+ value
					+ ')"  title="编辑"><i class="fa fa-edit"></i></buttoun>'
			</p:btn>
			<p:btn value="del">
			html += '<button class="btn btn-default btn-sm" onClick="myGrid.delItem('
					+ value
					+ ')" title="删除"><i class="fa fa-lg fa-trash-o"></i></buttoun>';
			</p:btn>
			html += ''
			return html;
		}

		function fordate(str) {
			var date = new Date(str);
			var year = date.getFullYear();
			var month = date.getMonth() + 1;
			var day = date.getDate();
			if (day < 10) {
				day = "0" + day;
			}
			return year + "-" + month + "-" + day;
		}

		//父子表，拼接字表
		function InitSubTable(index, row, $detail) {
			var parentid = row.MENU_ID;
			var thead = '<thead><tr><th>序号</th><th>领款人</th> <th>领款金额</th><th>领款日期</th><th data-align="center" style="width:65px;">操作</th></tr></thead>';
			var cur_table = $detail.html(
					'<table  class="table table-hover" >' + thead + '</table>')
					.find('table');
			var schList = row.schList;
			var html = "";
			for (var i = 0; i < schList.length; i++) {
				html += '<tr>'
						+ '<td>'
						+ (i + 1)
						+ '</td>'
						+ '<td>'
						+ schList[i].ucPeople
						+ '</td>'
						+ '<td>'
						+ schList[i].ucMoney
						+ '</td>'
						+ '<td>'
						+ fordate(schList[i].ucRdate)
						+ '</td>'
						/* +'<td>'+isnull(paymentList[i].pOperator)+'</td>' */
						+ '<td>'
						+ '<button class="btn btn-default btn-sm"  onClick="openEdit('
						+ schList[i].ucId
						+ ')"  title="编辑"><i class="fa fa-edit"></i></buttoun>'
						+ '</td>' + '</tr>';
			}
			cur_table.append(html);
		}

		//打开添加界面
		<p:btn value="add">
		function openAdd() {
			layer.open({
				type : 2,
				title : "添加信息",
				area : [ MUI.SIZE_L, '500px' ],
				content : [ '${path}/admin/schoolmanage/editForm' ]
			});
		}
		</p:btn>

		//打开编辑界面
		<p:btn value="edit">
		function openEdit(id) {
			console.log(id);
			layer.open({
				type : 2,
				title : "编辑院校管理费",
				area : [ MUI.SIZE_L, '500px' ],
				maxmin : true,
				content : [ '${path}/admin/schoolmanage/editForm?id=' + id ]
			});
		}
		</p:btn>

		//弹出导入数据的页面
		<p:btn value="import">
		function openImport() {
			//弹出修改框
			layer.open({
				type : 2,
				title : "批量导入",
				area : [ MUI.SIZE_L, '300px' ],
				maxmin : true,
				content : [ '${path}/admin/redirect/courseImportDialog' ]
			});
		}
		</p:btn>

		/* 导出excel */
		<p:btn value="export">
		function exportExcel() {
			var couName = $("#couName").val();
			var couCost = $("#couCost").val();
			window.location.href = "${path}/admin/course/exportExcel?couName="
					+ couName + "&couCost=" + couCost;
		}
		</p:btn>
	</script>
</body>
</html>
